package com.czjtxy.extraTerm.controller.employeemodule;

import com.czjtxy.extraTerm.entity.VO.TemployeeVO;
import com.czjtxy.extraTerm.server.EmployeeService;
import com.czjtxy.extraTerm.serverImpl.EmployeeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @program: staff-house
 * @author: MingYi
 * @create: 2021/07/01 15:21
 */
@WebServlet(name = "EmployeeServlet", value = "/EmployeeServlet")
public class EmployeeServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        EmployeeService employeeService = new EmployeeServiceImpl();
        List<TemployeeVO> temployeeVOS = null;
        try {
            temployeeVOS = employeeService.getAll();
            req.setAttribute("temployees", temployeeVOS);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        req.getRequestDispatcher("employee/employee.jsp").forward(req, resp);
    }
}
